/*------------------------------------------------------------------------------
 **     Ident: Delivery Center Java
 **    Author: rene
 ** Copyright: (c) Feb 26, 2012 Sogeti Nederland B.V. All Rights Reserved.
 **------------------------------------------------------------------------------
 ** Sogeti Nederland B.V.            |  No part of this file may be reproduced  
 ** Distributed Software Engineering |  or transmitted in any form or by any        
 ** Lange Dreef 17                   |  means, electronic or mechanical, for the      
 ** 4131 NJ Vianen                   |  purpose, without the express written    
 ** The Netherlands                  |  permission of the copyright holder.
 *------------------------------------------------------------------------------
 */
package com.yangfei.SportAssistant.mapProvider;

import com.yangfei.SportAssistant.R;
import com.yangfei.SportAssistant.util.Constants;
import com.yangfei.SportAssistant.util.PreferencesUtils;

import android.content.Context;
import android.content.SharedPreferences;
import android.util.Log;

/**
 * ????
 *
 * @version $Id:$
 * @author rene (c) Feb 26, 2012, Sogeti B.V.
 */
public class CommonLoggerMap
{
   private static final String TAG = "OGT.CommonLoggerMap";
   
   static public Class<?> getMapClass(Context ctx)
   {
     Class<?> mapClass = BaiduMap.class;
     
     String pKey = PreferencesUtils.getKey(ctx, R.string.map_source_key);
     SharedPreferences sp = ctx.getSharedPreferences(Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
     int provider = sp.getInt(pKey, 0);
     switch (provider)
     {
        case Constants.BAIDU:
           mapClass = BaiduMap.class;
           break;
        case Constants.OSM:
           mapClass = OsmLoggerMap.class;
           break;
        case Constants.MAPQUEST:
           mapClass = MapQuestLoggerMap.class;
           break;
        case Constants.GOOGLE:
          mapClass = GoogleLoggerMap.class;
          break;
        default:
           mapClass = BaiduMap.class;
           Log.e(TAG, "Fault in value " + provider + " as MapProvider, defaulting to Google Maps.");
           break;
     }
     
     return mapClass;
   }
}
